const Router = require('koa-router');
const response = require('../libs/result');
const bankinfo = require('../dict/bankinfo');
const eduction = require('../dict/eduction');
const loan_remark = require('../dict/loan_remark');
const religion = require('../dict/religion');
const usertype = require('../dict/usertype');
const orderstatus = require('../dict/orderstatus');
let router = new Router();

/**
 * @api {post} /api/v1/dict/getdic  获取字典
 * @apiDescription 获取字典
 * @apiName getdic
 * @apiParam (参数) {int} dictype   dictype 1教育程度  2宗教 3借款用途 4用户类型 5银行 6订单状态 7用户设置
 * @apiSampleRequest /api/v1/dict/getdic
 * @apiGroup dict
 * @apiVersion 1.0.0
 */
router.post('/getdic', async ctx => {
    let { dictype } = ctx.request.body;
    //let eduction = [{ name: "DIPLOMA_I", val: 1 }, { name: "DIPLOMA_II", val: 2 }, { name: "DIPLOMA_III", val: 3 }, { name: "SD", val: 4 }, { name: "SLTP", val: 5 }, { name: "SLTA", val: 6 }, { name: "S1", val: 7 }, { name: "S2", val: 8 }, { name: "S3", val: 9 }]
    //let religion = [{ name: "Islam", val: 1 }, { name: "Kekristenan", val: 2 }, { name: "Katolik", val: 3 }, { name: "Agama Hindu", val: 4 }, { name: "Agama Buddha", val: 5 }, { name: "Konfusianisme", val: 6 }]
    //let loan_remark = [{ name: "Konsumsi harian", val: 1 }, { name: "Bepergian", val: 2 }, { name: "Dekorasi", val: 3 }, { name: "Pendidikan", val: 4 }, { name: "Medis", val: 5 }, { name: "Perputaran modal", val: 6 }]
    //let usertype = [{ name: "Untuk bekerja", val: 1 }, { name: "Pelajar", val: 2 }]
    
    //let orderstatus = [{ name: "待补充材料", val: 80 }, { name: "审核中", val: 90 }, { name: "审批资料重填", val: 99 }, { name: "审批通过", val: 100 }, { name: "审批不通过", val: 110 }, { name: "贷款取消", val: 161 }, { name: "放款失败", val: 169 }, { name: "贷款取消", val: 161 }, { name: "放款成功", val: 170 }, { name: "还款期", val: 175 }, { name: "逾期", val: 180 }, { name: "宽限期", val: 185 }, { name: "贷款结清", val: 200 }]
    if (dictype == 1) {
        response(ctx, 200, eduction, 'dict');
        return;
    }
    if (dictype == 2) {
        response(ctx, 200, religion, 'dict');
        return;
    }
    if (dictype == 3) {
        response(ctx, 200, loan_remark, 'dict');
        return;
    }
    if (dictype == 4) {
        response(ctx, 200, usertype, 'dict');
        return;
    }
    if (dictype == 5) {
        response(ctx, 200, bankinfo, 'dict');
        return;
    }
    if (dictype == 6) {
        response(ctx, 200, orderstatus, 'dict');
        return;
    }
    if (dictype == 7) {
        let contcat = [  "PARENT","FRIEND"]
          
        let userneed = {
            edu: eduction,
            rel: religion,
            remark: loan_remark,
            utype: usertype,
            ucontact:contcat
        }
        response(ctx, 200, userneed, 'dict');
    }

})


module.exports = router.routes()